using System;
using Microsoft.Xna.Framework;

namespace EntitiesAndGameState
{
  public class X
  {
    public Vector3 Position;
    public bool IsEnable = false;
    public X(bool status)
    {
      IsEnable = status;
      Position = Vector3.Zero;
    }
    public X(Vector3 pos,bool status)
    {
      IsEnable = status;
      Position = pos;
    }
  }

  public class ShipToRemove
  {
    //tipo di spazzatura
    public GarbageType garbage_type;
    public bool remove_it = false;
  }

  public class ShipToAdd
  {
    public ShipToAdd() { }
    public ShipToAdd(Vector3 st, Vector3 des, bool isTouch, float vel, GarbageType gt, bool isEnable, bool isOterOpt)
    {
      Start = st;
      Dest = des;
      IsTouchEnable = isTouch;
      velocity = vel;
      Garbagetype = gt;
      IsEnable = isEnable;
      ManualVelocity = isOterOpt;
    }
    public GarbageType Garbagetype { get; set; }
    public Vector3 Dest { get; set; }
    public Vector3 Start { get; set; }
    public bool IsTouchEnable = true;
    public float velocity = 0.0f;

    private bool _ManualVelocity = false;
    public bool ManualVelocity { get { return _ManualVelocity; } set { _ManualVelocity = value; } }

    private bool _isEnable = false;
    public bool IsEnable { get { return _isEnable; } set { _isEnable = value; } }
  }

  public class GarbageSacToAdd
  {
    public int DimMin { get; set; }
    public int DimMax { get; set; }
    public int Vel { get; set; }

    private bool _isEnable = false;
    public bool IsEnable { get { return _isEnable; } set { _isEnable = value; } }
  }

  public class UtilsWAG
  {



    public static void add_garbage_sac(State s, GarbageSacToAdd sac)
    {
      for (int i = 0; i < s.asteroids_to_add.Length; i++)
      {
        //var garbage = s.asteroids_to_add.FirstOrDefault(en => en.IsEnable = false);
        if (s.asteroids_to_add[i].IsEnable == false)
        {
          s.asteroids_to_add[i].DimMax = sac.DimMax;
          s.asteroids_to_add[i].DimMin = sac.DimMin;
          s.asteroids_to_add[i].Vel = sac.Vel;
          s.asteroids_to_add[i].IsEnable = true;
          i = s.asteroids_to_add.Length;
        }
      }
    }

    public static Vector3[] generateStartDestinationPoints(float difficulty, Random random)
    {
      if (difficulty > 1) difficulty = 1;
      if (difficulty < 0) difficulty = 0;
      var start = random.Next(2);
      if (start == 0)
      {
        Vector3 startPoint = new Vector3((float)random.NextDouble() * 16.5f - 8.2f, 0, -6.8f);
        float xDiff = (16.6f * difficulty) - 8.3f;
        var randomPoint = (float)random.NextDouble() * (12.65f - xDiff);
        Vector3 destinationPoint = new Vector3(randomPoint + xDiff, 0, 8);
        Vector3[] final = { startPoint, destinationPoint };
        return final;
      }
      else
      {
        Vector3 startPoint = new Vector3(-13.1f, 0, (float)random.NextDouble() * 4.9f - 1.9f);
        float xDiff = (4.9f * difficulty) - 3f;
        var randomPoint = (float)random.NextDouble() * (7.9f - xDiff);
        Vector3 destinationPoint = new Vector3(12.65f, 0, randomPoint + xDiff);
        Vector3[] final = { startPoint, destinationPoint };
        return final;
      }
    }
  }
}
